// 
// DotNetNuke?- http://www.dotnetnuke.com 
// Copyright (c) 2002-2011 
// by DotNetNuke Corporation 
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
// to permit persons to whom the Software is furnished to do so, subject to the following conditions: 
// 
// The above copyright notice and this permission notice shall be included in all copies or substantial portions 
// of the Software. 
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
// DEALINGS IN THE SOFTWARE. 
// 

using System;
using System.Configuration;
using System.Data;
using System.Xml;
using System.Web;
using System.Collections.Generic;

using DotNetNuke;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Services.Search;
using DotNetNuke.Entities.Modules;

namespace CharityGamesOnline.Modules.Game.Trivia
{

    /// ----------------------------------------------------------------------------- 
    /// <summary> 
    /// The Controller class for Trivia 
    /// </summary> 
    /// <remarks> 
    /// </remarks> 
    /// <history> 
    /// </history> 
    /// ----------------------------------------------------------------------------- 
    public class TriviaController
    {
        public const int DEFAULT_CATEGORY_CNT = 5;
        public const int DEFAULT_QUESTION_CNT = 10;

        #region "Public Methods"

        public TriviaQuestionInfo GetQuestion(int enrollID, int userID)
        {
            return (TriviaQuestionInfo)CBO.FillObject(DataProvider.Instance().GetQuestion(enrollID, userID), typeof(TriviaQuestionInfo));
        }

        public List<TriviaAnswerInfo> GetAnswers(int enrollID, int userID, int questionIndex)
        {
            return CBO.FillCollection<TriviaAnswerInfo>(DataProvider.Instance().GetAnswers(enrollID, userID, questionIndex));
        }

        public TriviaResultSummaryInfo GetResultSummary(int enrollID, int userID)
        {
            return (TriviaResultSummaryInfo)CBO.FillObject(DataProvider.Instance().GetResultSummary(enrollID, userID), typeof(TriviaResultSummaryInfo));            
        }

        public int QuestionInitialize(int enrollID, int userID)
        {
            return QuestionInitialize(enrollID, userID, DEFAULT_CATEGORY_CNT, DEFAULT_QUESTION_CNT);
        }
        public int QuestionInitialize(int enrollID, int userID, int cntCategory, int cntQuestion)
        {
            return DataProvider.Instance().QuestionInitialize(enrollID, userID, cntCategory, cntQuestion); 
        }

        public int QuestionRegenerate(int enrollID, int userID)
        {
            return DataProvider.Instance().QuestionRegenerate(enrollID, userID);
        }

        public int QuestionAnswer(int enrollID, int userID, int questionIndex, int answerID, float gameDuration, int answerScore)
        {
            return DataProvider.Instance().QuestionAnswer(enrollID, userID, questionIndex, answerID, gameDuration, answerScore);
        }

        #endregion        
    }
}